ci: make the tree rustfmt-clean and gate on it - #4
Conversation
Purely mechanical: `cargo fmt --all` with default settings, no hand edits. Verified idempotent (a second run is a no-op), and 91 tests plus clippy --all-targets -D warnings are unchanged after it. Separated from the CI gate that follows so this diff can be skimmed as "rustfmt output" rather than reviewed line by line. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PfAfAujueuZ3rDTiL9apx3
Now that the tree is rustfmt-clean, enforce it. Without a gate, formatting drifts silently and every contributor's format-on-save produces diff noise unrelated to their change. Skips rust-cache deliberately: rustfmt parses sources and never builds, so there is nothing to restore and the cache round-trip would cost more than the job. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PfAfAujueuZ3rDTiL9apx3
|
Warning Review limit reached
Next review available in: 48 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis pull request adds a GitHub Actions formatting check and applies ChangesRust formatting
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/ci.yml:
- Around line 48-54: Restrict the fmt job’s GITHUB_TOKEN permissions by adding a
job-level permissions block granting only read access to repository contents.
Keep the existing checkout configuration unchanged.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 5746b3d3-f038-49cd-80ea-88b6bccf6303
📒 Files selected for processing (21)
.github/workflows/ci.ymlcrates/agent/src/lib.rscrates/auth/src/codex.rscrates/auth/src/lib.rscrates/auth/src/openrouter.rscrates/auth/src/pkce.rscrates/cli/src/agents.rscrates/cli/src/main.rscrates/harness/src/lib.rscrates/harness/src/pen.rscrates/llm/src/anthropic.rscrates/llm/src/chatcompletions.rscrates/llm/src/codex.rscrates/llm/src/lib.rscrates/sandbox/src/lib.rscrates/store/src/lib.rscrates/store/src/recovery.rscrates/tools/src/bash.rscrates/tools/src/fs.rscrates/tools/src/lib.rscrates/tools/src/search.rs
Without a permissions block, every job inherits the repository default. That default is currently read, but it is a repo setting anyone can widen, and the workflow would silently follow it. Declared at workflow level rather than per-job so a job added later cannot quietly inherit something broader. CI only ever reads the repo. Found by zizmor (excessive-permissions) via CodeRabbit, which flagged the new fmt job; test and clippy had the same gap. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PfAfAujueuZ3rDTiL9apx3
Closes the one deliberate gap left by the CI work: formatting was unenforced because the tree was not rustfmt-clean.
Why now, and why not a config
Before reformatting, I tested whether a
rustfmt.tomlcould be tuned to match the existing hand-formatted style instead. It cannot:max_width = 110max_width = 120use_small_heuristics = "Max"Nothing approaches zero. The tree is formatted case-by-case — sometimes more broken up than rustfmt wants, sometimes less — which no single config reproduces. That left a binary choice, and enforcing the standard formatter is the one that stops the drift.
Two commits, deliberately
style: apply cargo fmt across the workspaceis purecargo fmt --alloutput with no hand edits, so it can be skimmed as "rustfmt did this" rather than reviewed line by line.ci: gate on cargo fmt --checkadds the job. Reviewing them separately is much cheaper than reviewing the squashed diff.Verification
cargo fmt --all --checkclean, and idempotent (a second run is a no-op)cargo clippy --all-targets -- -D warningsstill silentfmtjob passes locally before being pushedThe
fmtjob skipsrust-cacheon purpose: rustfmt parses sources and never builds, so there is nothing to restore and the cache round-trip would cost more than the job.Post-Deploy Monitoring & Validation
Expect four green jobs (
test×2,fmt,clippy). Thefmtjob should be among the fastest since it does no compilation. Going forward, a redfmtmeans someone committed unformatted code — the fix is alwayscargo fmt --all, never editing the job. rustfmt ships in the pinned toolchain, so contributors already have the matching version.No runtime or production impact — formatting and CI configuration only.
Summary by CodeRabbit